import { CoreAli } from './../../aliyun'
import { Member } from './../../member'
import { AccountGroup } from './account-group.entity'
import { AccountLevel } from './account-level.entity'
import { Entity, PrimaryGeneratedColumn, OneToMany, ManyToOne, JoinColumn, OneToOne } from 'typeorm'
import { Shop } from '../../shop/shop.entity'
import { AccountWechat } from './account-wechat.entity'
import { SmsSetting } from '../../sms'

@Entity()
export class Account {
  @PrimaryGeneratedColumn()
  id: number

  @OneToMany(type => Shop, shop => shop.account)
  shops: Shop[]

  @ManyToOne(type => AccountLevel, level => level.accounts)
  level: AccountLevel

  @ManyToOne(type => AccountGroup, group => group.accounts)
  group: AccountGroup

  @ManyToOne(type => Member, member => member.accounts)
  owner: Member

  @OneToMany(type => Member, member => member.account)
  members: Member[]

  // 一个账号可以有多个微信账号
  @OneToMany(type => AccountWechat, wechat => wechat.account, {
    eager: true
  })
  @JoinColumn()
  wechats: AccountWechat[]

  @OneToMany(type => CoreAli, ali => ali.account)
  alis: CoreAli[]
}
